package merchant.space;

import java.util.ArrayList;

import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ViewItemsAdapter extends BaseAdapter {
	
	
	 private Activity mContext;
	 private ArrayList<Item> items;
	 private Collection collection; 

	    public ViewItemsAdapter(Activity c,Collection coll) {
	        mContext = c;
	        collection= coll;
	        items=collection.getItems();
	       
	        
	    }

	    public int getCount() {
	        return items.size();
	    }

	    public Object getItem(int position) {
	       return items.get(position);
	    }

	    public long getItemId(int position) {
	    	return items.get(position).getId();
	    }

	    // create a new ImageView for each item referenced by the Adapter
	    public View getView(int position, View convertView, ViewGroup parent) {
	        
	    	
	   // 	Log.d("GETTING","VIEW");
	    	LayoutInflater inflater = mContext.getLayoutInflater();
	        convertView = inflater.inflate(R.layout.grid_item, parent, false);
	        
	      //  context.getExpandableListView().setDivider(context.getResources().getDrawable(R.color.super_blue));
	        Item item = items.get(position);
	        
	        ((TextView) convertView.findViewById(R.id.title)).setText(item.getTitle());
	       
	        ImageView image = (ImageView) convertView.findViewById(R.id.image);
	              
	        image.setImageBitmap(item.getThumb());
	        
	        return convertView;
	    }
	    	
	    	
	    	

}
